home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / business / s3not10.zip / BIB.EDT < prev    next >
Text File  |  1992-09-14  |  10KB  |  280 lines

  1. /*
  2. ******************************************
  3. *     Variable Declaration Section
  4. ******************************************
  5. */
  6.  
  7. typedef struct {
  8.    bool    abort,
  9.            noneedited,
  10.            bypass,
  11.            edited,
  12.            finished,
  13.            fld_in_range;
  14.    int     sno,
  15.            fno,
  16.            incy,
  17.            last_fld;
  18.    winptr  winp,
  19.            edtwin;
  20. } editGlobalVars;
  21.  
  22. typedef struct {
  23.    int     sno,
  24.            fno,
  25.            incy;
  26.    winptr  winp;
  27. } dispGlobalVars;
  28.  
  29. editGlobalVars      edt;
  30. dispGlobalVars      dsp;
  31.  
  32.  
  33. /*
  34. ******************************************
  35. *     Function Declaration Section
  36. ******************************************
  37. */
  38.  
  39.  
  40. void dspf(int x, int y, byte a, byte s, byte l, fldtyp *f)
  41. {
  42.       dsp_fld((byte)x, (byte)(y + dsp.incy), f->faddr, f->typ, f->pic, s, l, a, dsp.winp);
  43. }
  44.  
  45. /*************************************************************************/
  46.  
  47. void BIB_dsp(int fno, int sno, byte incy)
  48. {
  49.    dsp.fno   = fno;
  50.    dsp.sno   = sno;
  51.    dsp.incy  = incy;
  52.    dsp.winp  = uw.wa[sno];
  53.    switch(sno) {
  54.       case 1 : 
  55.           if (dsp.fno ==  1) {
  56.               if (dsp.fno == filno) attrib = _av; else attrib = _iv;
  57.                             dspf(19, 2,0,0,0,&BIB1._AUTHOR);
  58.                             dspf(19, 3,0,0,0,&BIB1._TITLE);
  59.                             dspf(19, 4,0,0,0,&BIB1._PUBLICATION);
  60.                             dspf(19, 5,0,0,0,&BIB1._PUBLISHER);
  61.                             dspf(19, 6,0,0,0,&BIB1._DATE);
  62.                             dspf(19, 7,0,0,0,&BIB1._PAGES);
  63.                             dspf(19, 9,0,0,0,&BIB1._KEY1);
  64.                             dspf(19,10,0,0,0,&BIB1._KEY2);
  65.                             dspf(19,11,0,0,0,&BIB1._KEY3);
  66.                             dspf(45, 9,0,0,0,&BIB1._KEY4);
  67.                             dspf(45,10,0,0,0,&BIB1._KEY5);
  68.                             dspf(45,11,0,0,0,&BIB1._KEY6);
  69.               dspm(19,13,0,(byte)(dsp.sno),BIB1.datasize,&BIB1._MEMO,datf[ 1],dsp.winp);
  70.           }
  71.       break;
  72.    }
  73. }
  74.  
  75. /*************************************************************************/
  76.  
  77. bool skipfield(int fnum)
  78. {
  79.    bool tb;
  80.  
  81.    tb = False;
  82.    if (edt.sno ==  1) switch (fnum) {
  83.        case 0 : break;
  84.    }
  85.    return(tb);
  86. }
  87.  
  88. /*************************************************************************/
  89.  
  90. bool chk_fld(int chknum)
  91. {
  92.    string estr;
  93.  
  94.    *estr = '\0';
  95.    if (edt.sno ==  1) switch (chknum) {
  96.        case 0 : break;
  97.    }
  98.    if (*estr != '\0') {
  99.       audible(Error);
  100.       message(edt.winp, estr);
  101.    }
  102.    return (bool)(*estr == '\0');
  103. }
  104.  
  105. /*************************************************************************/
  106.  
  107. void edt_n_chk(byte x, byte y, byte l, byte a, winptr h, fldtyp *f, int fldno)
  108. {
  109.    if (!skipfield(fldno)) {
  110.       do {
  111.          if (!edt.bypass) {
  112.             edt_fld(x, y + edt.incy, f->faddr, f->typ, f->pic, l, a, edt.winp);
  113.             edt.noneedited = False;
  114.             edt.edited     = True;
  115.             edt.abort      = False;
  116.             if (exitcode == HlpKey) disphelp(h);
  117.             if (custom_key(scrno, edt.fno, &fldnum, &exitcode)) exitcode = QitKey;
  118.          }
  119.          if ((exitcode != QitKey) && (exitcode != UArr) && (exitcode != HlpKey)) {
  120.             edt.fld_in_range = chk_fld(fldno);
  121.                dsp_fld(x, y+edt.incy, f->faddr, f->typ, f->pic, 0, l, a, edt.winp);
  122.  
  123.             if (!edt.fld_in_range) {
  124.                fldnum = fldno;
  125.                edt.bypass = False;
  126.             }
  127.          }
  128.       } while (!edt.fld_in_range && (exitcode != QitKey) && (exitcode != UArr));
  129.       message(NULL,"");
  130.    }
  131. }
  132.  
  133. /*************************************************************************/
  134.  
  135. void openedtmnu(void)
  136. {
  137.    string editHelpString;
  138.  
  139.    strcpy(editHelpString, _EdtHelp);
  140.    if (openwin(0, (byte)(scrwid - strlen(editHelpString) + 1), scrhgt, (byte)(strlen(editHelpString)), 1, 0x4F, 0x4F, 0, "\0┐│┘─└│┌", TopCnt,"")) {
  141.       edt.edtwin = curwin;
  142.       writewxy(editHelpString, 0, 1, 1, edt.edtwin);
  143.       hidewin(T_ON, edt.edtwin);
  144.    }
  145.    else edt.edtwin = NULL;
  146. }
  147.  
  148. /*************************************************************************/
  149.  
  150. void BIB_edt(int fno, int fld, int incy)
  151. {
  152.    openedtmnu();
  153.    attrib         = _av;
  154.    exitcode       = Nul;
  155.    edt.fno        = fno;
  156.    edt.sno        = scrno;
  157.    edt.incy       = incy;
  158.    edt.winp       = uw.wa[edt.sno];
  159.    edt.abort      = True;
  160.    edt.noneedited = True;
  161.    edt.bypass     = False;
  162.    edt.finished   = False;
  163.    fldnum = (fld == 0) ? 1 : fld;
  164.  
  165.    do {
  166.       if (fldnum == 1) edt.noneedited = True;
  167.       if (edt_spos && (edt.last_fld != fldnum)) edt_spos = 1;
  168.       edt.last_fld = fldnum;
  169.       edt.edited   = False;
  170.  
  171.       if (edt.sno ==  1) switch (fldnum) {
  172.           case 1 : if (edt.fno ==  1)          edt_n_chk(19, 2,0,0,hw.wa[1],&BIB1._AUTHOR,fldnum); break;
  173.           case 2 : if (edt.fno ==  1)          edt_n_chk(19, 3,0,0,hw.wa[2],&BIB1._TITLE,fldnum); break;
  174.           case 3 : if (edt.fno ==  1)          edt_n_chk(19, 4,0,0,hw.wa[3],&BIB1._PUBLICATION,fldnum); break;
  175.           case 4 : if (edt.fno ==  1)          edt_n_chk(19, 5,0,0,hw.wa[4],&BIB1._PUBLISHER,fldnum); break;
  176.           case 5 : if (edt.fno ==  1)          edt_n_chk(19, 6,0,0,hw.wa[5],&BIB1._DATE,fldnum); break;
  177.           case 6 : if (edt.fno ==  1)          edt_n_chk(19, 7,0,0,hw.wa[6],&BIB1._PAGES,fldnum); break;
  178.           case 7 : if (edt.fno ==  1)          edt_n_chk(19, 9,0,0,hw.wa[7],&BIB1._KEY1,fldnum); break;
  179.           case 8 : if (edt.fno ==  1)          edt_n_chk(19,10,0,0,hw.wa[7],&BIB1._KEY2,fldnum); break;
  180.           case 9 : if (edt.fno ==  1)          edt_n_chk(19,11,0,0,hw.wa[7],&BIB1._KEY3,fldnum); break;
  181.           case 10 : if (edt.fno ==  1)          edt_n_chk(45, 9,0,0,hw.wa[7],&BIB1._KEY4,fldnum); break;
  182.           case 11 : if (edt.fno ==  1)          edt_n_chk(45,10,0,0,hw.wa[7],&BIB1._KEY5,fldnum); break;
  183.           case 12 : if (edt.fno ==  1)          edt_n_chk(45,11,0,0,hw.wa[7],&BIB1._KEY6,fldnum); break;
  184.           case 13 : if ((edt.fno ==  1) && !edt.bypass && !skipfield(fldnum)) {
  185.               edt.noneedited = False;
  186.               editmemo(19,13,0,BIB1.datasize,&BIB1._MEMO,
  187.               &BIB1,edt.winp,hw.wa[8],datf[ 1],&recno[ 1]); break;
  188.           }
  189.           default : if (edt.noneedited) {
  190.               edt.finished = True;
  191.               if (edt.abort) {
  192.                   exitcode = QitKey;
  193.                   dberrm(_NoneEdited);
  194.               }
  195.           }
  196.           else if (exitcode == XeptKey) edt.finished = True; else fldnum =           0;
  197.       }
  198.  
  199.       if (edt.bypass || !edt.edited) {
  200.          if (_upward && (fldnum > 1)) fldnum--;
  201.          else                         fldnum++;
  202.       }
  203.  
  204.       if (exitcode == XeptKey)    edt.bypass   = True;
  205.       if (exitcode == QitKey)     edt.finished = True;
  206.       if (fldnum > edt.last_fld) _upward       = False;
  207.  
  208.    } while (!edt.finished);
  209.    if (edt.edtwin != NULL) closewin(&edt.edtwin);
  210. }
  211.  
  212. /*************************************************************************/
  213.  
  214. void editdefaultdata(int fno, ptr fb)
  215. {
  216.    byte    lengthOfText,
  217.            lengthOfPrompt,
  218.            windowX,
  219.            windowY,
  220.            windowWidth,
  221.            windowHeight;
  222.    int     fieldNumber,
  223.            saveFieldNumber;
  224.    winptr  aWindowPtr;
  225.    fldblk *aFieldBlock;
  226.    fldtyp *aFieldType;
  227.    string  tempString;
  228.    fldtyp  editArray[23];
  229.    char   colon[10];
  230.  
  231.    strcpy(colon, " : ");
  232.    aFieldBlock     = fb;
  233.    saveFieldNumber = fldnum;
  234.    lengthOfPrompt  = lengthOfText = windowWidth = windowHeight = 0;
  235.  
  236.    for (fieldNumber=0; fieldNumber < aFieldBlock->numf; fieldNumber++) {
  237.       windowHeight++;
  238.       aFieldType = &(*aFieldBlock->farr)[fieldNumber];
  239.       if (aFieldType->typ != _Memo && gvar->sec >= aFieldType->dsec && windowHeight < 23) {
  240.          if (strlen(aFieldType->fname) > lengthOfPrompt) lengthOfPrompt = strlen(aFieldType->fname);
  241.          if (strlen(aFieldType->faddr) > lengthOfText)   lengthOfText   = strlen(aFieldType->faddr);
  242.          memmove(&editArray[windowHeight], aFieldType, sizeof(fldtyp));
  243.       }
  244.    }
  245.  
  246.    lengthOfPrompt = lengthOfPrompt + 3;
  247.    if ((lengthOfPrompt + lengthOfText) > (scrwid - 2)) lengthOfText = scrwid - 2 - lengthOfPrompt;
  248.    if (windowHeight > (scrhgt - 2))                    windowHeight = scrhgt - 2;
  249.  
  250.    windowWidth  = lengthOfPrompt + lengthOfText;
  251.    windowX      = (int)((scrwid - windowWidth) / 2);
  252.    windowY      = (int)((scrhgt - windowHeight) / 2);
  253.  
  254.    if (openwin(0, windowX, windowY, windowWidth, windowHeight, 15, 31, 8, "─┐│┘─└│┌", TopCnt, "")) {
  255.       aWindowPtr = curwin;
  256.       for (fieldNumber = 1; fieldNumber <= aFieldBlock->numf; fieldNumber++) {
  257.          aFieldType = &editArray[fieldNumber];
  258.          if (aFieldType->typ != _Memo && gvar->sec >= aFieldType->dsec) {
  259.             strcpy(tempString, aFieldType->fname);
  260.             strcat(tempString, colon);
  261.             writewxy(tempString, 0, 1, (byte)(fieldNumber), aWindowPtr);
  262.             dsp_fld(lengthOfPrompt + 1, fieldNumber, aFieldType->faddr, aFieldType->typ, aFieldType->pic, 0, lengthOfText, 0, aWindowPtr);
  263.          }
  264.       }
  265.  
  266.       hidewin(T_ON, aWindowPtr);
  267.       fieldNumber = 1;
  268.       do {
  269.          aFieldType = &editArray[fieldNumber];
  270.          edt_fld(lengthOfPrompt + 1, fieldNumber, aFieldType->faddr, aFieldType->typ, aFieldType->pic, lengthOfText, 0, aWindowPtr);
  271.          if (_upward)                    fieldNumber--;
  272.          else                            fieldNumber++;
  273.          if (!fieldNumber)               fieldNumber = windowHeight;
  274.          if (fieldNumber > windowHeight) fieldNumber = 1;
  275.       } while(exitcode != QitKey && exitcode != XeptKey);
  276.       closewin(&aWindowPtr);
  277.    }
  278.    fldnum = saveFieldNumber;
  279. }
  280.